$(function(){
    var id = $("#wedTypeId").val();
    if(id){
        $.ajax({
            type : "post",
            url : "htmlWeb/getDict",
            data: {"id" : id},
            async: false,
            success : function(data){
                var str = "";
                data = trimEmpty(data);
                $("#typeCode").val(data.code);
                $("#typeName").val(data.name);
            },
            error : function(data){
                console.log(data);
            }
        });
    }

    $(".save").click(function () {
        var options = {
            url: '/htmlWeb/submitDict',
            type: 'post',
            success: function (data) {
                $.ajaxSetup({cache: false});
                cancle();
            },
            error:function () {
                $.ajaxSetup({cache: false});
                tip("婚礼预算失败");
                cancle();
            }
        };
        $("#form").ajaxForm(options);
    });
    $("#typeCode").on("keyup",function () {
        if(!/^[0-9]*$/.test(this.value)){
            tip("请输入数字!");
            $(this).val("");
        }
    });
});


function cancle() {
    navPills("/htmlWeb/systemWedTypeHtml");
}